package pishen;

import java.io.Serializable;
import java.util.ArrayList;

public class Author implements Serializable, Comparable<Author> {
	private static final long serialVersionUID = 8559371447029748117L;
	public static final int weightOfRecommend = 3, weightOfArrow = 1;
	private String name;
	private double prestige;
	private int numOfPush, numOfArrow, numOfHiss;
	private ArrayList<String> articleList = new ArrayList<String>();
	private ArrayList<String> pushList = new ArrayList<String>();
	private ArrayList<String> arrowList = new ArrayList<String>();
	private ArrayList<String> hissList = new ArrayList<String>();

	public Author(String name) {
		this.name = name;
	}

	public int getNumOfPush() {
		return this.numOfPush;
	}

	public int getNumOfArrow() {
		return this.numOfArrow;
	}

	public int getNumOfHiss() {
		return this.numOfHiss;
	}

	public int getNumOfSimpleArticle() {
		return articleList.size();
	}

	public String getSimpleArticleName(int index) {
		return articleList.get(index);
	}

	public String getName() {
		return name;
	}

	public void addSimpleArticle(String name) {
		articleList.add(name);
	}

	public void addPush(String target) {
		if (!pushList.contains(target)) {
			pushList.add(target);
			numOfPush++;
		}
	}

	public void addArrow(String target) {
		if (!arrowList.contains(target)) {
			arrowList.add(target);
			numOfArrow++;
		}
	}

	public void addHiss(String target) {
		if (!hissList.contains(target)) {
			hissList.add(target);
			numOfHiss++;
		}
	}

	public String getPushTarget(int index) {
		return pushList.get(index);
	}

	public String getArrowTarget(int index) {
		return arrowList.get(index);
	}

	public String getHissTarget(int index) {
		return hissList.get(index);
	}
	
	public boolean containsHiss(String targetArticle){
		return hissList.contains(targetArticle);
	}
	
	public void setPrestige(double newPrestige){
		this.prestige = newPrestige;
	}
	
	public void addPrestige(double addedPrestige){
		this.prestige += addedPrestige;
	}
	
	public double getPrestige(){
		return prestige;
	}

	@Override
	public int compareTo(Author a) {
		// descending order
		if (this.prestige - a.getPrestige() > 0) {
			return -1;
		} else if (this.prestige - a.getPrestige() < 0) {
			return 1;
		} else {
			return 0;
		}
	}
}
